package com.atguigu.gmall.order.config;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import org.springframework.amqp.core.*;

/**
 * @author 搭忆长安
 * @version 1.0
 * @date 2021年07月12日 20:44
 * @ClassName:DeadLetterMqConfig
 * @Description: TODO
 */
@Configuration
public class DeadLetterMqConfig {

    /**
     * 定义正常队列
     */
    @Bean("order_pay_queue_wx")
    public Queue orderPayQueueWx(){
        return QueueBuilder.durable("order_pay_queue_wx").build();
    }

    /**
     * 定义正常队列
     */
    @Bean("order_pay_queue_zfb")
    public Queue orderPayQueueZfb(){
        return QueueBuilder.durable("order_pay_queue_zfb").build();
    }

    /**
     * 正常交换机
     */
    @Bean("Exchange")
    public Exchange normalExchange(){
        return ExchangeBuilder.directExchange("exchange").build();
    }



    /**
     * 定义绑定:正常交换机和正常队列绑定
     */
    @Bean
    public Binding normalBindingWx(@Qualifier("order_pay_queue_wx") Queue orderPayQueueWx,
                                 @Qualifier("Exchange") Exchange normalExchange){
        return BindingBuilder.bind(orderPayQueueWx).to(normalExchange).with("pay.order.result").noargs();
    }

    /**
     * 定义绑定:正常交换机和正常队列绑定
     */
    @Bean
    public Binding normalBindingZfb(@Qualifier("order_pay_queue_zfb") Queue orderPayQueueZfb,
                                 @Qualifier("Exchange") Exchange normalExchange){
        return BindingBuilder.bind(orderPayQueueZfb).to(normalExchange).with("pay.order.result").noargs();
    }
}
